a11y: Implement missing atspi.Component getters
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 11 Nov 2020 17:43:44 +0000 (17:43 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 11 Nov 2020 18:33:15 +0000 (18:33 +0000)
Some of them are entirely innocuous, and we can easily provide values
that match what GTK3 provides.

gtk/a11y/gtkatspicomponent.c
gtk/a11y/gtkatspiprivate.h

index 2ab1ffc81c85e22a1148e8e08c6d0b718c44501e..7da968d1d1dffc5c81b2809fc9cc1fd172736fd4 100644 (file)
@@ -26,7 +26,9 @@
 #include "gtkatspiprivate.h"
 #include "gtkatspiutilsprivate.h"
 #include "gtkaccessibleprivate.h"
+#include "gtkpopover.h"
 #include "gtkwidget.h"
+#include "gtkwindow.h"
 
 #include "a11y/atspi/atspi-component.h"
 
@@ -194,11 +196,20 @@ component_handle_method (GDBusConnection       *connection,
     }
   else if (g_strcmp0 (method_name, "GetLayer") == 0)
     {
-      g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "");
+      AtspiComponentLayer layer;
+
+      if (GTK_IS_WINDOW (widget))
+        layer = ATSPI_COMPONENT_LAYER_WINDOW;
+      else if (GTK_IS_POPOVER (widget))
+        layer = ATSPI_COMPONENT_LAYER_POPUP;
+      else
+        layer = ATSPI_COMPONENT_LAYER_WIDGET;
+
+      g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", layer));
     }
   else if (g_strcmp0 (method_name, "GetMDIZOrder") == 0)
     {
-      g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "");
+      g_dbus_method_invocation_return_value (invocation, g_variant_new ("(n)", 0));
     }
   else if (g_strcmp0 (method_name, "GrabFocus") == 0)
     {
@@ -206,7 +217,9 @@ component_handle_method (GDBusConnection       *connection,
     }
   else if (g_strcmp0 (method_name, "GetAlpha") == 0)
     {
-      g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "");
+      double opacity = gtk_widget_get_opacity (widget);
+
+      g_dbus_method_invocation_return_value (invocation, g_variant_new ("(d)", opacity));
     }
   else if (g_strcmp0 (method_name, "SetExtents") == 0)
     {
index 9d3d316354c972a493d4ebb8f29871bd5966655f..036a41ef2742cedaeca3fa7238bf7c5f8f1692af 100644 (file)
@@ -252,4 +252,16 @@ typedef enum {
   ATSPI_COORD_TYPE_PARENT,
 } AtspiCoordType;
 
+typedef enum {
+  ATSPI_COMPONENT_LAYER_INVALID,
+  ATSPI_COMPONENT_LAYER_BACKGROUND,
+  ATSPI_COMPONENT_LAYER_CANVAS,
+  ATSPI_COMPONENT_LAYER_WIDGET,
+  ATSPI_COMPONENT_LAYER_MDI,
+  ATSPI_COMPONENT_LAYER_POPUP,
+  ATSPI_COMPONENT_LAYER_OVERLAY,
+  ATSPI_COMPONENT_LAYER_WINDOW
+} AtspiComponentLayer;
+
+
 G_END_DECLS